import Vue from 'vue'
import VueRouter from 'vue-router'
import main from '../views/main.vue'
import login from '../views/login.vue'
import register from '../views/register.vue'
// 配置路由实例
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/login',
  
  },
  {
    path:'/main',
    name: 'main',
    component: ()=>import ('../views/main.vue')
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/login.vue')
  },
  {
    path: '/select',
    name: 'select',
    component: () => import('../views/select.vue')
  },
  {
    path: '/mine',
    name: 'mine',
    component: () => import('../views/mine.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/register.vue')
  },
  {
    path:'/pay',
    name:'pay',
    component:()=>import('../views/pay.vue')
  },
  {
    path:'*',
    name:'404',
    component:()=>import('../views/login.vue')
  }
]

// 将routes挂载到router上，router作为全局的路由管理器，routes是routers的API,用来管理多个route
const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
